Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read and basic correlation for execution trace #57

Closed
wants to merge 8 commits into from

Conversation

briancoutinho
Copy link
Contributor

@briancoutinho briancoutinho commented Jul 15, 2023

What does this PR do?

Add ability to read and correlate execution trace explained in #58

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
    • N/A
  • Did you write any new necessary tests?
    • N/A
  • Did you make sure to update the docs?
    • N/A Feature as a whole is not yet ready, so we can wait till some of the foundational blocks are done
  • Did you update the changelog?
    • N/A

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 15, 2023
@louisfeng louisfeng self-requested a review July 18, 2023 17:33
@briancoutinho briancoutinho marked this pull request as ready for review July 21, 2023 22:20
@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2023

Codecov Report

Patch coverage: 94.23% and project coverage change: +0.19% 🎉

Comparison is base (d54e43f) 90.26% compared to head (f05e26f) 90.45%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
+ Coverage   90.26%   90.45%   +0.19%     
==========================================
  Files          27       29       +2     
  Lines        2044     2148     +104     
==========================================
+ Hits         1845     1943      +98     
- Misses        199      205       +6     
Files Changed Coverage Δ
hta/analyzers/cupti_counter_analysis.py 93.65% <ø> (ø)
hta/common/execution_trace.py 91.30% <91.30%> (ø)
hta/common/trace.py 87.37% <100.00%> (+0.08%) ⬆️
tests/test_execution_trace.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

CHANGELOG.md Outdated Show resolved Hide resolved
et = ExecutionGraph(json.load(f))
t_end = time.perf_counter()

t_end = time.perf_counter()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need t_end twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh my bad, copy pasted extra one


def _et_has_overlap(trace_df: pd.DataFrame, et: ExecutionGraph) -> bool:
"""Use record function IDs (rf_id) to find out if ET and Kineto trace
have overlap"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the same documentation style as in the function above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this is an internal function hence didn't let me fix this

hta/common/execution_trace.py Show resolved Hide resolved
if "et_node" not in trace_df:
logger.error("Please run correlate_execution_trace() first")
return
if column == "op_schema":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would be returned if any of the if/elif blocks from line 135-164 are reached? only the function definition is called. are the functions executed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the function is used as a lambda / mapping function below. Initially I had lambdas but there was a lint suggesting not assigning lambda to variable.

https://www.flake8rules.com/rules/E731.html#:~:text=Lambdas%20should%20not%20be%20assigned,will%20display%20the%20function's%20name.

@@ -91,6 +91,14 @@ def get_sym_id_map(self) -> Dict[str, int]:
def get_sym_table(self) -> List[str]:
return self.sym_table

def add_back_symbols(self, trace_df: pd.dataframe, col: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a "back" symbol? do you mean append symbol to dataframe, as it may have been removed earlier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea adding back the string symbols, should i call it expand_symbols() or something?

requirements.txt Outdated
@@ -3,3 +3,4 @@ jupyterlab>=3.5.1
numpy>=1.23.5
pandas>=1.5.2
plotly>=5.11.0
pydot>=1.3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? where is it being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check if this is required or not, it is being imported in execution trace file so I added it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it being added to execution_trace.py or are you referring to some other file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execution_trace.py uses param -> which uses pydot import. I tried and we cannot run the notebook without it

Copy link
Contributor

@anupambhatnagar anupambhatnagar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the notebook,

  • "Collecting PyTorch trace is covered in the official PyTorch recipe here. " does not contain the hyperlink.
  • Code Cell 3 can be cleaned up. there are two trace_dir statements.

@anupambhatnagar
Copy link
Contributor

@briancoutinho Do you want to add documentation for this new feature?

import sys
import time

from typing import List # Dict, , NamedTuple, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove commented code.

@anupambhatnagar anupambhatnagar self-requested a review July 26, 2023 18:09
Copy link
Contributor

@anupambhatnagar anupambhatnagar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for implementing execution trace support to HTA @briancoutinho

@briancoutinho
Copy link
Contributor Author

@briancoutinho Do you want to add documentation for this new feature?

@anupambhatnagar i'll add it in a follow up :)

@facebook-github-bot
Copy link
Contributor

@briancoutinho has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@briancoutinho has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@briancoutinho merged this pull request in c24333b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants